package com.aircms.service.impl;

import com.aircms.common.ServerResponse;
import com.aircms.dao.UserRoleMapper;
import com.aircms.pojo.UserRole;
import com.aircms.service.IUserRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service(value ="iUserRoleService" )
public class UserRoleServiceImpl implements IUserRoleService {
    private static final Logger logger=LoggerFactory.getLogger(UserRoleServiceImpl.class);

    @Autowired
    private UserRoleMapper userRoleMapper;

    /**
     * 获取用户拥有的角色
     * @param userId
     * @return
     */
    public ServerResponse getUserRole(Integer userId){
        List<UserRole> userRole=userRoleMapper.selectUserRole(userId);
        logger.error(String.valueOf(userRole));
        return ServerResponse.resResponse(userRole);
    }

    public ServerResponse deleteUserRole(Integer userId,Integer roleId){
        userRoleMapper.deleteUserRole(userId,roleId);
        return ServerResponse.resResponse();
    }
}
